package com.initialize.pub.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2019/12/16
 * Time: 下午5:06
 * To change this template use File | Settings | File Templates.
 * Description: 这是迷你版本的Redis的配置类,因为这是自己封装的
 *           只够一些基本的使用
 */
@Configuration
public class MiniRedisConfig {

    @Value("${mini-redis.password}")
    private String password;

    @Value("${mini-redis.host}")
    private String host;


    @Bean
    public Jedis createJedis() {
        if ("".equals(password.trim())) {
            password = null;
        }
        Jedis jedis = new Jedis(host);
        jedis.auth(password);
        return jedis;
    }

}